package org.csu.mybigpro.controller;

import org.csu.mybigpro.domain.InteractionTool;
import org.csu.mybigpro.service.InteractionToolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/interaction-tool")
public class InteractionToolController {
    @Autowired
    private InteractionToolService interactionToolService;

    @GetMapping("/{id}")
    public InteractionTool getById(@PathVariable Long id) {
        return interactionToolService.getById(id);
    }

    @GetMapping("/list")
    public List<InteractionTool> list() {
        return interactionToolService.list();
    }

    @PostMapping("/add")
    public boolean add(@RequestBody InteractionTool tool) {
        return interactionToolService.save(tool);
    }

    @PostMapping("/update")
    public boolean update(@RequestBody InteractionTool tool) {
        return interactionToolService.updateById(tool);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return interactionToolService.removeById(id);
    }
}